package com.zzyl.nursing.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zzyl.nursing.mapper.OrderMapper;
import com.zzyl.nursing.service.OrderService;
import com.zzyl.serve.domain.NursingProject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, NursingProject> implements OrderService {

    private static final Logger logger = LoggerFactory.getLogger(OrderServiceImpl.class);

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public PageInfo<NursingProject> getOrders(String name, int pageNum, int pageSize, Long status) {
        PageHelper.startPage(pageNum, pageSize);
        List<NursingProject> list = orderMapper.getOrders(name, status);
        PageInfo<NursingProject> pageInfo = new PageInfo<>(list);
        logger.info("Total Records: {}", pageInfo.getTotal());

        return pageInfo;
    }

    @Override
    public NursingProject getOrderById(Long id) {
        return orderMapper.getOrderById(id);
    }
}